package com.zyz.friend.controller.exam;

import com.zyz.common.core.constants.HttpConstants;
import com.zyz.common.core.model.Result;
import com.zyz.common.core.model.TableDataInfo;
import com.zyz.friend.model.exam.dto.ExamQueryDTO;
import com.zyz.friend.model.exam.dto.ExamRankDTO;
import com.zyz.friend.service.exam.IExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
public class ExamController {

    @Autowired
    private IExamService examService;

    @RequestMapping(value = "semiLogin/list",method = RequestMethod.GET)
    public TableDataInfo list (ExamQueryDTO examDTO) {
        return examService.list(examDTO);
    }

    @RequestMapping(value = "semiLogin/redis/list",method = RequestMethod.GET)
    public TableDataInfo redisList (@RequestHeader(value = HttpConstants.AUTHENTICATION,required = false)String token, ExamQueryDTO examDTO) {
        return examService.redisList(token,examDTO);
    }

    @RequestMapping(value = "semiLogin/listByTime",method = RequestMethod.GET)
    private TableDataInfo listByTime(ExamQueryDTO examDTO) {
        return examService.listByTime(examDTO);
    }

    @RequestMapping(value = "/getFirstQuestion",method = RequestMethod.GET)
    public Result<String> getFirstQuestion(Long examId) {
        return Result.ok(examService.firstQuestion(examId));
    }

    @RequestMapping(value = "/preQuestion",method = RequestMethod.GET)
    public Result<String> preQuestion(Long examId ,Long questionId) {
        return Result.ok(examService.preQuestion(examId,questionId));
    }

    @RequestMapping(value = "/nextQuestion",method = RequestMethod.GET)
    public Result<String> nextQuestion(Long examId ,Long questionId) {
        return Result.ok(examService.nextQuestion(examId,questionId));
    }

    @RequestMapping(value = "semiLogin/rank/list",method = RequestMethod.GET)
    public TableDataInfo rank (ExamRankDTO rankDTO) {
        return examService.rankList(rankDTO);
    }

}

